package com.linsen.erp.admin.controller;


import com.linsen.erp.admin.provider.qo.LoginLogQo;
import com.linsen.erp.admin.provider.vo.AnalyseVO;
import com.linsen.erp.admin.provider.vo.LoginLogVO;
import com.linsen.erp.admin.service.ILoginLogService;
import com.linsen.core.common.util.Result;
import com.linsen.core.mybatisplus.util.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 登录日志 前端控制器
 * </p>
 *
 * @author zhaoyong
 * @since 2023-07-24
 */
@RestController
@RequestMapping("/admin/login-log")
@RequiredArgsConstructor
@Api(tags = "登录日志")
public class LoginLogController {
    private final ILoginLogService iLoginLogService;

    //@SaCheckPermission("admin:login-log:page")
    @PostMapping("/page")
    @ApiOperation(value = "分页查询",response = LoginLogVO.class)
    public Result page(@RequestBody LoginLogQo loginLogQo) {
        return Result.data(PageUtil.convert(this.iLoginLogService.page(loginLogQo),LoginLogVO.class));
    }

    @GetMapping("/last")
    @ApiOperation(value = "当前用户最近一次登录信息",response = LoginLogVO.class)
    public Result last() {
        return Result.data(this.iLoginLogService.last());
    }

    @PostMapping("/analyse")
    @ApiOperation(value = "系统访问趋势图",response = AnalyseVO.class)
    public Result analyse() {
        return Result.data(this.iLoginLogService.analyse());
    }
}
